package com.example.styservice.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.example.styinterface.interfaces.IKafkaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


@Component //必要
@Service
public class KafkaServiceImpl implements IKafkaService {
    @Autowired
    private KafkaTemplate<Object, Object> template;

    public void sendFoo(@PathVariable String input) {
        this.template.send("test", input);
    }
    @KafkaListener(id = "webGroup", topics = "test")
    public void listen(String input) {
        System.out.println("输入信息:"+input);
    }
}
